/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ControlLayer;
import ModelLayer.*;
import DBLayer.*;
import java.util.ArrayList;
/**
 *
 * @author Stefan
 */
public class CtrInvoice {
    /** Creates a new instance of CtrInvoice */
    public CtrInvoice() {

    }
    public ArrayList findAllInvoices()
    {
      IFDBInvoice dbVoice = new DBInvoice();
      ArrayList allInvoices = new ArrayList();
      allInvoices = dbVoice.getAllInvoices(false);
      return allInvoices;
    }

    public Invoice findByNo(int id)
    {
        IFDBInvoice dbInvoice = new DBInvoice();
        return dbInvoice.findInvoice( id, true);
    }

    public int updateInvoice(int no, String date, int type, int method)
    {
          IFDBInvoice dbInvoice = new DBInvoice();
          Invoice voice = new Invoice();
          voice.setInvoiceNo(no);
          voice.setPaymentDate(date);
          voice.setPaymentType(type);
          voice.setPaymentMethod(method);
          return  dbInvoice.updateInvoice(voice);


    }

    public void insertNew(Invoice invoice)
    {
       IFDBInvoice dbInvoice = new DBInvoice();
       dbInvoice.insertInvoice(invoice);
    }

    public void deleteInvoice(int no)
    {
        IFDBInvoice dbInvoice = new DBInvoice();
        dbInvoice.deleteInvoice(no);
    }
}
